Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ability to specify which timezones to include in the native imagee… #1819

Merged
merged 1 commit into from
Nov 15, 2019
Merged

Introduce ability to specify which timezones to include in the native imagee… #1819

merged 1 commit into from
Nov 15, 2019

Conversation

jaikiran
Copy link
Contributor

@jaikiran jaikiran commented Nov 8, 2019

Currently when a native-image is built it by defaults adds only GMT, UTC and the default zone id as the timezones that are initialized and made available in the generated image. Of course, there's IncludeAllTimeZones option which includes all the available timezones into the target image.

However, it would be better to expose an additional option which lets users decide which specific timezones to include in the target image. Quarkus project has seen issues like these[1] where even a GMT expressed as a different id Etc/GMT isn't available in the target image. Of course, that's just one use case. Having a more finer control on which timezones get included in the target image will help users in configuring the native-image build accordingly or allowing frameworks like Quarkus an ability to add them intelligently.

This is my first contribution to the graal project. However, I have a signed and approved OCA (as part of the JDK project) and here's my record in the census https://openjdk.java.net/census#jpai

I have done manual tests with these changes to verify that using the new IncludeTimeZones option indeed includes the specific timezones in the target image and also made sure the exisitng IncludeAllTimeZones option isn't regressed. I am willing to add an automated test case (couldn't find documentation for it) if someone can guide me or point me to how to do that.

[1] quarkusio/quarkus#5269

@graalvmbot
Copy link
Collaborator

Hello Jaikiran Pai, thanks for contributing a PR to our project!

We use the Oracle Contributor Agreement to make the copyright of contributions clear. We don't have a record of you having signed this yet, based on your email address jaikiran -(dot)- pai -(at)- gmail -(dot)- com. You can sign it at that link.

If you think you've already signed it, please comment below and we'll check.

@jaikiran
Copy link
Contributor Author

jaikiran commented Nov 8, 2019

If you think you've already signed it, please comment below and we'll check.

Please check for the user jpai https://openjdk.java.net/census#jpai

@graalvmbot
Copy link
Collaborator

Jaikiran Pai has signed the Oracle Contributor Agreement (based on email address jaikiran -(dot)- pai -(at)- gmail -(dot)- com) so can contribute to this repository.

@@ -78,12 +78,23 @@ public static TimeZone getTimeZone(String id) {
static class Options {
@Option(help = "When true, all time zones will be pre-initialized in the image.")//
public static final HostedOptionKey<Boolean> IncludeAllTimeZones = new HostedOptionKey<>(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is the right default value. How much does -H:+IncludeAllTimeZones cost in terms of image size?

Anyhow, this is out of the scope of this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much does -H:+IncludeAllTimeZones cost in terms of image size?

We have been having this similar conversation in the Quarkus project https://groups.google.com/forum/#!msg/quarkus-dev/J1afzAhpShI/A5vmUGJLAQAJ

My experiments (with a couple of different programs, one being the HelloWorld example used in substratevm project) have shown that when IncludeAllTimeZones isn't set then the filesize is something along lines of 2.9M:

ls -lh helloworld 
-rwxr-xr-x  1 jaikiran  jaikiran   2.9M Nov 14 23:22 helloworld

and when you set IncludeAllTimeZones, the size increases very slightly to:

-rwxr-xr-x  1 jaikiran  jaikiran   3.3M Nov 14 23:50 ./helloworld

So not a big difference really. So yes, by default including all timezones probably will help application frameworks like Quarkus, where in certain situations there isn't really an easy way to determine at build time which timezones will be needed in the native image (imagine an application which communicates with a DB server whose timezone information can only be obtained at runtime).

But yes, like you say, the default value of IncludeAllTimeZones is something that needs to be discussed and sorted out separately.

@@ -76,18 +76,27 @@ public static TimeZone getTimeZone(String id) {
@AutomaticFeature
final class TimeZoneFeature implements Feature {
static class Options {
private static final TimeZone defaultZone = TimeZone.getDefault();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of static state, but I guess this one is OK to stay here.

@graalvmbot graalvmbot merged commit e32c01a into oracle:master Nov 15, 2019
@jaikiran jaikiran deleted the timezone-support branch November 16, 2019 03:25
@jaikiran
Copy link
Contributor Author

@vjovanov Thank you very much for reviewing this and merging it.

For the question of the default value for IncludeAllTimeZones, I have created a separate issue here #1833

@aruffie
Copy link

aruffie commented May 14, 2021

I confirm too, I have the bug here: quarkiverse/quarkus-univocity-parsers@5321516 the timezone is different between my non-native test phase and the native test phase. I think the "-H:+IncludeAllTimeZones" isn't take in account

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants